import java.util.Timer;
import java.util.TimerTask;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: qian
 * Date: 2023-01-13
 * Time: 12:22
 */

//标准的定时器
public class test2 {
    public static void main(String[] args) {
        Timer timer=new Timer();
        //任务1
        timer.schedule(new TimerTask() {
                           @Override
                           public void run() {
                               System.out.println("时间到，快起床");
                           }
                       },3000
        );
        //任务2
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("该吃早餐了");
            }
        },5000);
        System.out.println("安排任务");
    }
}
